package com.mybatis.jpa.SqlProvider;

/**
 * @Author lgt
 * @Date 2017/10/10 : 21:49
 */
public class OrderBy {

    public static final String DESC = " DESC ";
    public static final String ASC = " ASC ";

    private StringBuffer condition;

    public OrderBy(String column, String direction) {
        condition = new StringBuffer(" ORDER BY ").append(column).append(" ").append(direction);
    }

    public OrderBy(String column) {
        condition = new StringBuffer(" ORDER BY ").append(column).append(" ").append(ASC);
    }

    public OrderBy orderBy(String column, String direction) {
        condition.append(" , ").append(column).append(" ").append(direction);
        return this;
    }

    @Override
    public String toString() {
        return condition.toString();
    }

}
